<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html">
	<meta charset="utf-8" />
	<meta http-equiv="X-UA-Compatible" content="IE=edge" />
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<title></title>
</head>
<body erke-hide>
</body>
<script>
/**
 * @param {number[][]} image
 * @param {number} sr
 * @param {number} sc
 * @param {number} newColor
 * @return {number[][]}
 */
var floodFill = function(image, sr, sc, newColor) {
	var w=image.length;
	var h=image[0].length;
	var oldColor=image[sr][sc];
	console.log(aAronDie(image,sr,sc,oldColor,'aAronDie',w,h));
	for(var i in image){
		for(var j in image[i]){
			if(image[i][j]=='aAronDie'){
				image[i][j]=newColor;
			};
		};
	};
	return image;
};
function aAronDie(arr,i,j,oldC,newC,w,h){
	arr[i][j]=newC;
	if(i-1>=0&&arr[i-1][j]==oldC){
		arr[i-1][j]=newC;
		aAronDie(arr,i-1,j,oldC,newC,w,h);
	};
	if(j-1>=0&&arr[i][j-1]==oldC){
		arr[i][j-1]=newC;
		aAronDie(arr,i,j-1,oldC,newC,w,h);
	};
	if(i+1<w&&arr[i+1][j]==oldC){
		arr[i+1][j]=newC;
		aAronDie(arr,i+1,j,oldC,newC,w,h);
	};
	if(j+1<h&&arr[i][j+1]==oldC){
		arr[i][j+1]=newC;
		aAronDie(arr,i,j+1,oldC,newC,w,h);
	};
	return arr;
};
var res=new floodFill([[0,0,0],[0,1,1]],1,1,1);
</script>
</html>